<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
    <script>
      var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'));
      document.write(
        '<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
          (coverSupport ? ', viewport-fit=cover' : '') +
          '" />'
      );
    </script>
    <title></title>
    <!--preload-links-->
    <!--app-context-->
    <script src="https://unpkg.com/vconsole@3.14.7/dist/vconsole.min.js"></script>
    <script type="text/javascript" src="//assets.zjzwfw.gov.cn/assets/ZWJSBridge/1.1.0/zwjsbridge.js"></script>
    <script type="text/javascript" src="//assets.zjzwfw.gov.cn/assets/zwlog/1.0.0/zwlog.js"></script>
  </head>
  <body>
    <div id="app"><!--app-html--></div>
    <script type="module" src="/src/main.ts"></script>
  </body>
  <script type="text/javascript">
    import { user, system } from '@/store';
    import util from '@/common/util/util.js';
    ZWJSBridge.onReady(() => {
      console.log('初始化完成');
    });
    //popstate
    window.addEventListener(
      'popstate',
      function (event) {
        console.log('popstate');
        console.log(event);
        let browerInfo = system.browerInfo;
        if (!browerInfo) {
          browerInfo = util.getBrowerInfo();
          system.setBrowerInfo(browerInfo);
        }
        let type = '';
        if (browerInfo) {
          type = browerInfo.browserType;
        }
        if (type != 'weixin') {
          if (ZWJSBridge) {
            try {
              ZWJSBridge.close()
                .then((result) => {
                  console.log(result);
                })
                .catch((error) => {
                  console.log(error);
                });
            } catch (e) {}
          }
        }

        if (AlipayJSBridge) {
          try {
            AlipayJSBridge.call('closeWebview');
          } catch (e) {
            console.log(e);
          }
        }
      },
      false
    );
    window.addEventListener(
      'pageshow',
      function (event) {
        let browerInfo = system.browerInfo;
        if (!browerInfo) {
          browerInfo = util.getBrowerInfo();
          system.setBrowerInfo(browerInfo);
        }
        let type = '';
        if (browerInfo) {
          type = browerInfo.browserType;
        }

        if (event.persisted || (window.performance && window.performance.navigation.type == 2)) {
          console.log('window.performance.navigation.type: ' + window.performance.navigation.type);
          if (type != 'weixin') {
            if (ZWJSBridge) {
              try {
                ZWJSBridge.close()
                  .then((result) => {
                    console.log(result);
                  })
                  .catch((error) => {
                    console.log(error);
                  });
              } catch (e) {}
            }
          }
          if (AlipayJSBridge) {
            try {
              AlipayJSBridge.call('closeWebview');
            } catch (e) {
              console.log(e);
            }
          }
        }
      },
      false
    );
    // VConsole 默认会挂载到 `window.VConsole` 上
    //var vConsole = new window.VConsole();
  </script>
</html>
